<?php

namespace App\Http\Controllers\Web\Oauth;

use App\Core\Utils\TwHelper\Environment;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use App\Http\Controllers\Web\Controller;
use TwOauth\Tongwei;
use TwOauth\TwSdk;
use TwOauth\Config;
use App\Services\Base\UserService;
use App\Http\Resources\Base\UserResource;
use App\Core\Entity\Cookie\UserEntity as CookieUserEntity;

/**
 * 头像修改、个人中心、设置中心等相关的跳转
 */
class PlusUserController extends Controller
{

    const SET_AVATAR_MOBIEL_URL = 'User/avatar.html';
    const SET_AVATAR_PC_URL ='User/index.html#/avatar';

    const CENTOR_MOBILE_URL = 'User/profile.html#/index';
    const CENTOR_PC_URL = 'User/index.html#/center';

    const SETTING_MOBILE_URL = 'User/setting.html#/index';
    const SETTING_PC_URL = 'User/index.html#/edit';

    const PASSWORD_MOBILE_URL = 'User/setting.html#/password';
    const PASSWORD_PC_URL = 'User/index.html#/password';
    /**
     * 头像修改
     */
    public function avatar()
    {
        if(Environment::isMobile()){
            $url = Config::getDomain().self::SET_AVATAR_MOBIEL_URL;
        }else{
            $url = Config::getDomain().self::SET_AVATAR_PC_URL;
        }
        return redirect($url);
    }

    /**
     * 个人中心
     */
    public function centor(Request $request)
    {
        if(Environment::isMobile()){
            $url = Config::getDomain().self::CENTOR_MOBILE_URL;
        }else{
            $url = Config::getDomain().self::CENTOR_PC_URL;
        }
        return redirect($url);
    }

    /**
     * 设置
     */
    public function setting(Request $request)
    {
        if(Environment::isMobile()){
            $url = Config::getDomain().self::SETTING_MOBILE_URL;
        }else{
            $url = Config::getDomain().self::SETTING_PC_URL;
        }
        return redirect($url);
    }
    
    /**
     * 修改密码
     */
    public function password(Request $request)
    {
        if(Environment::isMobile()){
            $url = Config::getDomain().self::PASSWORD_MOBILE_URL;
        }else{
            $url = Config::getDomain().self::PASSWORD_PC_URL;
        }
        return redirect($url);
    }
}